#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int maxArea(vector<int>& height) {
        int left = 0, right = height.size() - 1, ans = 0;
        while (left < right)
        {
            int v = min(height[left], height[right]) * (right - left);
            ans = max(v, ans);
            height[left] < height[right] ? left++ : right--;
        }
        return ans;
    }
};